<?php

// error reporting
foreach($this->element->getElements() as $element) {
	$name = htmlentities($element->getFullyQualifiedName(), ENT_QUOTES, 'UTF-8');
	$label = $element->getLabel();
	$messages = $element->getMessages();
	if (!empty($messages))
		$_SESSION['msg_errors'][$name] = array($label, $messages);
}

// values
$email = $this->element->getElement('email')->getValue() ? $this->element->getElement('email')->getValue() : $this->element->getElement('email')->getLabel();

?>
<form id="login_form" action="<?php echo $this->element->getAction(); ?>" method="<?php echo $this->element->getMethod(); ?>">
	<input type="text" name="email" tabindex="1" <?php if(isset($_SESSION['msg_errors']['email'])) echo 'class="red-error"'; ?> value="<?php if($email) echo $email; ?>" /><br />
	<input type="password" name="password" tabindex="2" <?php if(isset($_SESSION['msg_errors']['password'])) echo 'class="red-error"'; ?> value="passw" /><br />
	<input type="submit" value="Login" class="button" tabindex="3" name="login" />
</form>
<script type="text/javascript">
	var Loginaa = function() {
		var store = {
			translate: {
				a: '<?php echo $this->element->getElement('email')->getLabel(); ?>',
				b: 'passw'
			}

		// constructor
		}, __construct = function() {
			var sys = $('#login_form'),
				input_a = $("input[name='email']", sys),
				input_b = $("input[name='password']", sys);

			// on focus
			input_a.focus(function() { var f = $(this, sys); if(f.val() == store.translate.a) f.val(''); });
			input_b.focus(function() { var f = $(this, sys); if(f.val() == store.translate.b) f.val(''); });

			// on blur
			input_a.blur(function() { var f = $(this, sys); if(f.val() == '') f.val(store.translate.a); });
			input_b.blur(function() { var f = $(this, sys); if(f.val() == '') f.val(store.translate.b); });
		};

		// public, yay
		return {
			init: __construct
		}
	}();

	READY(Loginaa.init);
</script>